/*******************************************************************************
 * Copyright (c) 2012 Clever Devices.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 * 	Clever Devices Interns - 
 * 	Alex Frankel, Andria Young, Kevin Thomas, Nicholas Culpepper, Taner Oztimurlenk, Thomas Volberg
 ******************************************************************************/
package com.framework.beans;

/**
 * Holds all necessary prediction data.  Used in the construction of the
 * arrivals grid
 * 
 * @author AFrankel
 *
 */
public class Prediction {
	
	public Prediction(String stop, String vid, String rt, String des,
			String time, String prd){
		stopName = stop;
		vehicleId = vid;
		route = rt;
		destination = des;
		timestamp = time;
		prediction = prd;
	}
	
	public String getStopName(){return stopName;}
	public String getVehicleId(){return vehicleId;}
	public String getRoute(){return route;}
	public String getDestination(){return destination;}
	
	/**
	 * computes the difference between prediction and timestamp
	 * to display a "Minutes to arrive" dialog
	 * 
	 * @return difference in minutes between prediction and timestamp
	 */
	public int getPrediction(){
		String [] time = timestamp.split(" ");
		String [] pred = prediction.split(" ");
		String [] minutes = time[1].split(":");
		String [] pMinutes = pred[1].split(":");
		
		int timestampInMinutes = (Integer.parseInt(minutes[0])*60) + (Integer.parseInt(minutes[1]));
		int predictionInMinutes = (Integer.parseInt(pMinutes[0])*60) + (Integer.parseInt(pMinutes[1]));
		
		return predictionInMinutes - timestampInMinutes;
	}
	
	String stopName;
	String vehicleId;
	String route;
	String destination;
	String timestamp; //will have to parse to extract minutes
	String prediction; //will have to parse to extract minutes
}
